package com.bailiban.aigou.admin.utils;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;

public class HibernateUtil {
    private static SessionFactory sessionFactory=null;
    private static Session session=null;
    
    public static Session getSession(){
    	  if(session==null||!session.isConnected()){
    		  Configuration configuration=new Configuration().configure(); 
    		  sessionFactory=configuration.buildSessionFactory();
    		  session=sessionFactory.openSession();
    	  }
		return session;
    	
    }
    public static void CloseSeesion(){
    	if(session.isConnected()){
    		session.close();
    		sessionFactory.close();
    	}
    	
    }
}
